<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.7"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>qLibc: utilities/qencode.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">qLibc
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.7 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('qencode_8c.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">qencode.c File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Encoding/decoding APIs.  
<a href="#details">More...</a></p>

<p><a href="qencode_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:aaf5feec6e64a6f74b8916bde73a214f9"><td class="memItemLeft" align="right" valign="top">qlisttbl_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qencode_8c.html#aaf5feec6e64a6f74b8916bde73a214f9">qparse_queries</a> (qlisttbl_t *tbl, const char *query, char equalchar, char sepchar, int *count)</td></tr>
<tr class="memdesc:aaf5feec6e64a6f74b8916bde73a214f9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Parse URL encoded query string.  <br /></td></tr>
<tr class="separator:aaf5feec6e64a6f74b8916bde73a214f9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a711145c1cafb961bfb85d61f3e7761db"><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qencode_8c.html#a711145c1cafb961bfb85d61f3e7761db">qurl_encode</a> (const void *bin, size_t size)</td></tr>
<tr class="memdesc:a711145c1cafb961bfb85d61f3e7761db"><td class="mdescLeft">&#160;</td><td class="mdescRight">Encode data using URL encoding(Percent encoding) algorithm.  <br /></td></tr>
<tr class="separator:a711145c1cafb961bfb85d61f3e7761db"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adefa85504919e3790adff444d8604496"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qencode_8c.html#adefa85504919e3790adff444d8604496">qurl_decode</a> (char *str)</td></tr>
<tr class="memdesc:adefa85504919e3790adff444d8604496"><td class="mdescLeft">&#160;</td><td class="mdescRight">Decode URL encoded string.  <br /></td></tr>
<tr class="separator:adefa85504919e3790adff444d8604496"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a761de56d9987f1e312e6cd0587ec104d"><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qencode_8c.html#a761de56d9987f1e312e6cd0587ec104d">qbase64_encode</a> (const void *bin, size_t size)</td></tr>
<tr class="memdesc:a761de56d9987f1e312e6cd0587ec104d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Encode data using BASE64 algorithm.  <br /></td></tr>
<tr class="separator:a761de56d9987f1e312e6cd0587ec104d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5bb9ee36ce61ff6061c7d8a50cafdcbf"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qencode_8c.html#a5bb9ee36ce61ff6061c7d8a50cafdcbf">qbase64_decode</a> (char *str)</td></tr>
<tr class="memdesc:a5bb9ee36ce61ff6061c7d8a50cafdcbf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Decode BASE64 encoded string.  <br /></td></tr>
<tr class="separator:a5bb9ee36ce61ff6061c7d8a50cafdcbf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aff18a5ca486ff7af31425c4f012afd7a"><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qencode_8c.html#aff18a5ca486ff7af31425c4f012afd7a">qhex_encode</a> (const void *bin, size_t size)</td></tr>
<tr class="memdesc:aff18a5ca486ff7af31425c4f012afd7a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Encode data to Hexadecimal digit format.  <br /></td></tr>
<tr class="separator:aff18a5ca486ff7af31425c4f012afd7a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abe7be5bbdf9ee3928bf84f4663d272e8"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qencode_8c.html#abe7be5bbdf9ee3928bf84f4663d272e8">qhex_decode</a> (char *str)</td></tr>
<tr class="memdesc:abe7be5bbdf9ee3928bf84f4663d272e8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Decode Hexadecimal encoded data.  <br /></td></tr>
<tr class="separator:abe7be5bbdf9ee3928bf84f4663d272e8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Encoding/decoding APIs. </p>

<p class="definition">Definition in file <a class="el" href="qencode_8c_source.html">qencode.c</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="aaf5feec6e64a6f74b8916bde73a214f9" name="aaf5feec6e64a6f74b8916bde73a214f9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aaf5feec6e64a6f74b8916bde73a214f9">&#9670;&#160;</a></span>qparse_queries()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">qlisttbl_t * qparse_queries </td>
          <td>(</td>
          <td class="paramtype">qlisttbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>query</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char&#160;</td>
          <td class="paramname"><em>equalchar</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char&#160;</td>
          <td class="paramname"><em>sepchar</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>count</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Parse URL encoded query string. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>a pointer of qlisttbl_t container. NULL can be used to create new table. </td></tr>
    <tr><td class="paramname">query</td><td>URL encoded string. </td></tr>
    <tr><td class="paramname">equalchar</td><td>separater of key, value pair. </td></tr>
    <tr><td class="paramname">sepchar</td><td>separater of line. </td></tr>
    <tr><td class="paramname">count</td><td>if count is not NULL, a number of parsed entries are stored.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>qlisttbl container pointer, otherwise returns NULL.</dd></dl>
<div class="fragment"><div class="line">cont <span class="keywordtype">char</span> query = <span class="stringliteral">&quot;category=love&amp;str=%C5%A5%B5%F0%C4%DA%B4%F5&amp;sort=asc&quot;</span>;</div>
<div class="line">qlisttbl_t *tbl = <a class="code hl_function" href="qencode_8c.html#aaf5feec6e64a6f74b8916bde73a214f9">qparse_queries</a>(NULL, req-&gt;pszQueryString, <span class="charliteral">&#39;=&#39;</span>, <span class="charliteral">&#39;&amp;&#39;</span>, NULL);</div>
<div class="line">printf(<span class="stringliteral">&quot;category = %s\n&quot;</span>, tbl-&gt;get_str(tbl, <span class="stringliteral">&quot;category&quot;</span>, <span class="keyword">false</span>));</div>
<div class="line">printf(<span class="stringliteral">&quot;str = %s\n&quot;</span>, tbl-&gt;get_str(tbl, <span class="stringliteral">&quot;str&quot;</span>, <span class="keyword">false</span>));</div>
<div class="line">printf(<span class="stringliteral">&quot;sort = %s\n&quot;</span>, tbl-&gt;get_str(tbl, <span class="stringliteral">&quot;sort&quot;</span>, <span class="keyword">false</span>));</div>
<div class="line">tbl-&gt;free(tbl);</div>
<div class="ttc" id="aqencode_8c_html_aaf5feec6e64a6f74b8916bde73a214f9"><div class="ttname"><a href="qencode_8c.html#aaf5feec6e64a6f74b8916bde73a214f9">qparse_queries</a></div><div class="ttdeci">qlisttbl_t * qparse_queries(qlisttbl_t *tbl, const char *query, char equalchar, char sepchar, int *count)</div><div class="ttdoc">Parse URL encoded query string.</div><div class="ttdef"><b>Definition</b> <a href="qencode_8c_source.html#l00062">qencode.c:62</a></div></div>
</div><!-- fragment --> 
<p class="definition">Definition at line <a class="el" href="qencode_8c_source.html#l00062">62</a> of file <a class="el" href="qencode_8c_source.html">qencode.c</a>.</p>

</div>
</div>
<a id="a711145c1cafb961bfb85d61f3e7761db" name="a711145c1cafb961bfb85d61f3e7761db"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a711145c1cafb961bfb85d61f3e7761db">&#9670;&#160;</a></span>qurl_encode()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char * qurl_encode </td>
          <td>(</td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>bin</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Encode data using URL encoding(Percent encoding) algorithm. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">bin</td><td>a pointer of input data. </td></tr>
    <tr><td class="paramname">size</td><td>the length of input data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a malloced string pointer of URL encoded string in case of successful, otherwise returns NULL</dd></dl>
<div class="fragment"><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *text = <span class="stringliteral">&quot;hello &#39;qLibc&#39; world&quot;</span>;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">char</span> *encstr = <a class="code hl_function" href="qencode_8c.html#a711145c1cafb961bfb85d61f3e7761db">qurl_encode</a>(text, strlen(text));</div>
<div class="line"><span class="keywordflow">if</span>(encstr == NULL) <span class="keywordflow">return</span> -1;</div>
<div class="line"> </div>
<div class="line">printf(<span class="stringliteral">&quot;Original: %s\n&quot;</span>, text);</div>
<div class="line">printf(<span class="stringliteral">&quot;Encoded : %s\n&quot;</span>, encstr);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">size_t</span> decsize = <a class="code hl_function" href="qencode_8c.html#adefa85504919e3790adff444d8604496">qurl_decode</a>(encstr);</div>
<div class="line"> </div>
<div class="line">printf(<span class="stringliteral">&quot;Decoded : %s (%zu bytes)\n&quot;</span>, encstr, decsize);</div>
<div class="line">free(encstr);</div>
<div class="line"> </div>
<div class="line">--[output]--</div>
<div class="line">Original: hello <span class="stringliteral">&#39;qLibc&#39;</span> world</div>
<div class="line">Encoded:  hello%20%27qLibc%27%20world</div>
<div class="line">Decoded:  hello <span class="stringliteral">&#39;qLibc&#39;</span> world (19 bytes)</div>
<div class="ttc" id="aqencode_8c_html_a711145c1cafb961bfb85d61f3e7761db"><div class="ttname"><a href="qencode_8c.html#a711145c1cafb961bfb85d61f3e7761db">qurl_encode</a></div><div class="ttdeci">char * qurl_encode(const void *bin, size_t size)</div><div class="ttdoc">Encode data using URL encoding(Percent encoding) algorithm.</div><div class="ttdef"><b>Definition</b> <a href="qencode_8c_source.html#l00125">qencode.c:125</a></div></div>
<div class="ttc" id="aqencode_8c_html_adefa85504919e3790adff444d8604496"><div class="ttname"><a href="qencode_8c.html#adefa85504919e3790adff444d8604496">qurl_decode</a></div><div class="ttdeci">size_t qurl_decode(char *str)</div><div class="ttdoc">Decode URL encoded string.</div><div class="ttdef"><b>Definition</b> <a href="qencode_8c_source.html#l00192">qencode.c:192</a></div></div>
</div><!-- fragment --> 
<p class="definition">Definition at line <a class="el" href="qencode_8c_source.html#l00125">125</a> of file <a class="el" href="qencode_8c_source.html">qencode.c</a>.</p>

</div>
</div>
<a id="adefa85504919e3790adff444d8604496" name="adefa85504919e3790adff444d8604496"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adefa85504919e3790adff444d8604496">&#9670;&#160;</a></span>qurl_decode()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">size_t qurl_decode </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>str</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Decode URL encoded string. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">str</td><td>a pointer of URL encoded string.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the length of bytes stored in the str memory in case of successful, otherwise returns NULL</dd></dl>
<dl class="section note"><dt>Note</dt><dd>This modify str directly. And the 'str' is always terminated by NULL character. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qencode_8c_source.html#l00192">192</a> of file <a class="el" href="qencode_8c_source.html">qencode.c</a>.</p>

</div>
</div>
<a id="a761de56d9987f1e312e6cd0587ec104d" name="a761de56d9987f1e312e6cd0587ec104d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a761de56d9987f1e312e6cd0587ec104d">&#9670;&#160;</a></span>qbase64_encode()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char * qbase64_encode </td>
          <td>(</td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>bin</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Encode data using BASE64 algorithm. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">bin</td><td>a pointer of input data. </td></tr>
    <tr><td class="paramname">size</td><td>the length of input data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a malloced string pointer of BASE64 encoded string in case of successful, otherwise returns NULL</dd></dl>
<div class="fragment"><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *text = <span class="stringliteral">&quot;hello world&quot;</span>;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">char</span> *encstr = <a class="code hl_function" href="qencode_8c.html#a761de56d9987f1e312e6cd0587ec104d">qbase64_encode</a>(text, strlen(text));</div>
<div class="line"><span class="keywordflow">if</span>(encstr == NULL) <span class="keywordflow">return</span> -1;</div>
<div class="line"> </div>
<div class="line">printf(<span class="stringliteral">&quot;Original: %s\n&quot;</span>, text);</div>
<div class="line">printf(<span class="stringliteral">&quot;Encoded : %s\n&quot;</span>, encstr);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">size_t</span> decsize = <a class="code hl_function" href="qencode_8c.html#a5bb9ee36ce61ff6061c7d8a50cafdcbf">qbase64_decode</a>(encstr);</div>
<div class="line"> </div>
<div class="line">printf(<span class="stringliteral">&quot;Decoded : %s (%zu bytes)\n&quot;</span>, encstr, decsize);</div>
<div class="line">free(encstr);</div>
<div class="line"> </div>
<div class="line">--[output]--</div>
<div class="line">Original: hello world</div>
<div class="line">Encoded:  aGVsbG8gd29ybGQ=</div>
<div class="line">Decoded:  hello world (11 bytes)</div>
<div class="ttc" id="aqencode_8c_html_a5bb9ee36ce61ff6061c7d8a50cafdcbf"><div class="ttname"><a href="qencode_8c.html#a5bb9ee36ce61ff6061c7d8a50cafdcbf">qbase64_decode</a></div><div class="ttdeci">size_t qbase64_decode(char *str)</div><div class="ttdoc">Decode BASE64 encoded string.</div><div class="ttdef"><b>Definition</b> <a href="qencode_8c_source.html#l00308">qencode.c:308</a></div></div>
<div class="ttc" id="aqencode_8c_html_a761de56d9987f1e312e6cd0587ec104d"><div class="ttname"><a href="qencode_8c.html#a761de56d9987f1e312e6cd0587ec104d">qbase64_encode</a></div><div class="ttdeci">char * qbase64_encode(const void *bin, size_t size)</div><div class="ttdoc">Encode data using BASE64 algorithm.</div><div class="ttdef"><b>Definition</b> <a href="qencode_8c_source.html#l00249">qencode.c:249</a></div></div>
</div><!-- fragment --> 
<p class="definition">Definition at line <a class="el" href="qencode_8c_source.html#l00249">249</a> of file <a class="el" href="qencode_8c_source.html">qencode.c</a>.</p>

</div>
</div>
<a id="a5bb9ee36ce61ff6061c7d8a50cafdcbf" name="a5bb9ee36ce61ff6061c7d8a50cafdcbf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5bb9ee36ce61ff6061c7d8a50cafdcbf">&#9670;&#160;</a></span>qbase64_decode()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">size_t qbase64_decode </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>str</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Decode BASE64 encoded string. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">str</td><td>a pointer of Base64 encoded string.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the length of bytes stored in the str memory in case of successful, otherwise returns NULL</dd></dl>
<dl class="section note"><dt>Note</dt><dd>This modify str directly. And the 'str' is always terminated by NULL character. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qencode_8c_source.html#l00308">308</a> of file <a class="el" href="qencode_8c_source.html">qencode.c</a>.</p>

</div>
</div>
<a id="aff18a5ca486ff7af31425c4f012afd7a" name="aff18a5ca486ff7af31425c4f012afd7a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aff18a5ca486ff7af31425c4f012afd7a">&#9670;&#160;</a></span>qhex_encode()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char * qhex_encode </td>
          <td>(</td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>bin</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Encode data to Hexadecimal digit format. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">bin</td><td>a pointer of input data. </td></tr>
    <tr><td class="paramname">size</td><td>the length of input data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a malloced string pointer of Hexadecimal encoded string in case of successful, otherwise returns NULL</dd></dl>
<div class="fragment"><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *text = <span class="stringliteral">&quot;hello world&quot;</span>;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">char</span> *encstr = <a class="code hl_function" href="qencode_8c.html#aff18a5ca486ff7af31425c4f012afd7a">qhex_encode</a>(text, strlen(text));</div>
<div class="line"><span class="keywordflow">if</span>(encstr == NULL) <span class="keywordflow">return</span> -1;</div>
<div class="line"> </div>
<div class="line">printf(<span class="stringliteral">&quot;Original: %s\n&quot;</span>, text);</div>
<div class="line">printf(<span class="stringliteral">&quot;Encoded : %s\n&quot;</span>, encstr);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">size_t</span> decsize = <a class="code hl_function" href="qencode_8c.html#abe7be5bbdf9ee3928bf84f4663d272e8">qhex_decode</a>(encstr);</div>
<div class="line"> </div>
<div class="line">printf(<span class="stringliteral">&quot;Decoded : %s (%zu bytes)\n&quot;</span>, encstr, decsize);</div>
<div class="line">free(encstr);</div>
<div class="line"> </div>
<div class="line"><span class="keywordflow">return</span> 0;</div>
<div class="line"> </div>
<div class="line">--[output]--</div>
<div class="line">Original: hello world</div>
<div class="line">Encoded : 68656c6c6f20776f726c64</div>
<div class="line">Decoded : hello world (11 bytes)</div>
<div class="ttc" id="aqencode_8c_html_abe7be5bbdf9ee3928bf84f4663d272e8"><div class="ttname"><a href="qencode_8c.html#abe7be5bbdf9ee3928bf84f4663d272e8">qhex_decode</a></div><div class="ttdeci">size_t qhex_decode(char *str)</div><div class="ttdoc">Decode Hexadecimal encoded data.</div><div class="ttdef"><b>Definition</b> <a href="qencode_8c_source.html#l00426">qencode.c:426</a></div></div>
<div class="ttc" id="aqencode_8c_html_aff18a5ca486ff7af31425c4f012afd7a"><div class="ttname"><a href="qencode_8c.html#aff18a5ca486ff7af31425c4f012afd7a">qhex_encode</a></div><div class="ttdeci">char * qhex_encode(const void *bin, size_t size)</div><div class="ttdoc">Encode data to Hexadecimal digit format.</div><div class="ttdef"><b>Definition</b> <a href="qencode_8c_source.html#l00393">qencode.c:393</a></div></div>
</div><!-- fragment --> 
<p class="definition">Definition at line <a class="el" href="qencode_8c_source.html#l00393">393</a> of file <a class="el" href="qencode_8c_source.html">qencode.c</a>.</p>

</div>
</div>
<a id="abe7be5bbdf9ee3928bf84f4663d272e8" name="abe7be5bbdf9ee3928bf84f4663d272e8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abe7be5bbdf9ee3928bf84f4663d272e8">&#9670;&#160;</a></span>qhex_decode()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">size_t qhex_decode </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>str</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Decode Hexadecimal encoded data. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">str</td><td>a pointer of Hexadecimal encoded string.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the length of bytes stored in the str memory in case of successful, otherwise returns NULL</dd></dl>
<dl class="section note"><dt>Note</dt><dd>This modify str directly. And the 'str' is always terminated by NULL character. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qencode_8c_source.html#l00426">426</a> of file <a class="el" href="qencode_8c_source.html">qencode.c</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_7b5d38f1875f1b693f62ca6a108a1129.html">utilities</a></li><li class="navelem"><a class="el" href="qencode_8c.html">qencode.c</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.7 </li>
  </ul>
</div>
</body>
</html>
